package com.design.chainofresponsibility;

/**
 * @author leali
 * @title: ChainClient
 * @projectName design
 * @description: ChainClient
 * @date 2022/1/3 2:00
 */
public class ChainClient {
    public static void main(String[] args) {
        Approver director, vicePresident, president, meeting;
        director = new Director("张无忌");
        vicePresident = new VicePresident("杨过");
        president = new President("郭靖");
        meeting = new Congress("董事会");
        //新增测试
        Approver manager;
        manager = new Manager("黄蓉");
        //创建职责链
        director.setSuccessor(manager);
        //添加链
        manager.setSuccessor(vicePresident);
        vicePresident.setSuccessor(president);
        president.setSuccessor(meeting);

        //创建采购单
        PurchaseRequest pr1 = new PurchaseRequest(45000, 10001, "购买倚天剑");
        director.processRequest(pr1);

        PurchaseRequest pr2 = new PurchaseRequest(60000, 10002, "购买《葵花宝典》");
        director.processRequest(pr2);

        PurchaseRequest pr3 = new PurchaseRequest(160000, 10003, "购买《金刚经》");
        director.processRequest(pr3);

        PurchaseRequest pr4 = new PurchaseRequest(800000, 10004, "购买桃花岛");
        director.processRequest(pr4);
    }
}
